<?php
abstract class Pageley_Query_Condition_Aggregate implements Pageley_Query_Condition {
	private $conditions;
	private $sql;

	public function __construct($conditions) {
		$this->conditions = $conditions;
	}

	public abstract function getOperator();

	public function getValues() {
		$values = new Pageley_Util_ArrayMap();
		foreach($this->conditions as $condition) {
			$values->putAll($condition->getValues());
		}
		return $values;
	}

	public function setQuery($query) {
		foreach($this->conditions as $condition) {
			$condition->setQuery($query);
		}
	}

	public function getConditions() {
		return $this->conditions;
	}

	public function setConditions($conditions) {
		$this->conditions = $conditions;
	}

	public function __toString() {
		$string = null;
		foreach($this->conditions as $condition) {
			if($string === null) {
			    $string .= "( ";
			} else {
				$string .= " " . $this->getOperator() . " ";
			}
			$string .= $condition;
		}
		$string .= " )";
		return $string;
	}
}